/**
 * @Description:
 * @author 紫霞
 * @since 2019/1/17
 */
// React基础组件
import React from 'react'
// dva 连接组件 - 连接route和model
import { connect } from 'dva'
// 引入antd的组件
import { Form, Col, Row, Button, Input, Select, DatePicker, Radio, Cascader, Table, Checkbox, Tooltip, Tag, Upload, Icon, Modal, message } from 'antd'
import locale from 'antd/lib/date-picker/locale/zh_CN';
import moment from 'moment';
import 'moment/locale/zh-cn';
import { CollapsiblePanels } from 'widget/CollapsiblePanels/index'
moment.locale('zh-cn');
import { get, cloneDeep } from "lodash";
import PopUpSelect from 'widget/PopUpSelectnoModal/PopUpSelect'
const confirm = Modal.confirm;
const { TextArea } = Input;
const { RangePicker } = DatePicker;
const RadioGroup = Radio.Group;
const FormItem = Form.Item
const Option = Select.Option;
//引用listPage
import ListPage from 'widget/PageTmpl/ListPage'
//导入路由组件，用于跳转等
import { Link, hashHistory } from 'dva/router'
// 导入项目全局配置文件
import config from 'config/config'
import Cookie from 'js-cookie'
import Uploader from 'widget/Upload'
// 引入model取值工具方法
import { mapStateToProps } from 'utils/view_utils'


//引入富文本编辑器
import Editor from '../../../../widget/Editor/Editor'
import { calculate_object_name, uploadObject2OSS } from '../../../../utils/upload'
// import KingEditor from '../../../../widget/Editor/KingEditor.js'
import Ueditor from '../../../../widget/Editor/Ueditor.js'
import ImgCutting from 'widget/ImgCutting/ImgCuttingView';
import FlagBtn from 'widget/FlagBtn/FlagView'
import styles from './activityDetailStyle.less'
import classnames from 'classnames/bind'
let cx = classnames.bind(styles);

import activity_cover_01 from '../../../../assets/img/infoAndActivity/activity_cover_01.png'
import activityDetail_demo from '../../../../assets/img/infoAndActivity/activityDetail_demo.png'
import activity_apply_btn from '../../../../assets/img/infoAndActivity/activity_apply_btn.png'

import Track from 'widget/Map/Track'



import { relative } from 'path';


/**
 * description 路由视图及事件处理
 * dispatch 分发到models中的effects对应事件名
 * model 用于获取models中state定义的数据
 * form 表单对象
 */
const formItemLayout = {
  labelCol: { span: 8 },
  wrapperCol: { span: 16 },
}
const formItemLayout01 = {
  labelCol: { span: 4 },
  wrapperCol: { span: 20 },
}

const formItemLayout02 = {
  labelCol: { span: 7 },
  wrapperCol: { span: 17 },
}
const formItemLayout03 = {
  labelCol: { span: 5 },
  wrapperCol: { span: 19 },
}
const formItemLayout04 = {
  labelCol: { span: 16 },
  wrapperCol: { span: 6 },
}
const formItemLayout05 = {
  labelCol: { span: 4 },
  wrapperCol: { span: 20 },
}
const formItemLayout06 = {
  labelCol: { span: 4 },
  wrapperCol: { span: 4 },
}
const formItemLayout07 = {
  labelCol: { span: 11 },
  wrapperCol: { span: 11 },
}
const formItemLayout08 = {
  labelCol: { span: 8 },
  wrapperCol: { span: 14 },
}
const imageLayout = {
  labelCol: { span: 2 },
  wrapperCol: { span: 22 },
}
const routeView = function ({ dispatch, model, form }) {
  // 表单的子函数
  const { resetFields, getFieldDecorator, validateFields, setFieldsValue } = form
  // 取出model对象，命名空间
  const { modelObj, namespace } = model

  // modelObj.xxx获取model中状态机的值
  let { showEditor, editValue, disabledLink, detail, visible, tagALL, areaList, actionType, contentId, choiceType, choiceTypeTitle,
    estateList, showTime, activityId, Enroll, listData, imgModal, gif, isSubmit, selectItem, projectData, checkAll, indeterminate, activityApply, discountCouponList, giftList, payCodeList, getPayCodeList, templatesList, TypeModalFlag, hashUrl,Mapmodel} = modelObj
  const columns = [
    { title: '客户姓名', dataIndex: 'name', key: 'name' },
    { title: '手机号码', dataIndex: 'mobile', key: 'mobile' },
    { title: '身份证', dataIndex: 'idCardNo', key: 'idCardNo' },
    { title: '意向楼盘', dataIndex: 'intentionProductName', key: 'intentionProductName' },
    { title: '参加人数', dataIndex: 'applyCnt', key: 'applyCnt' },
    { title: '报名时间', dataIndex: 'createTime', key: 'createTime' },
  ];
  const columns1 = [
    { title: '客户姓名', dataIndex: 'name', key: 'name' },
    { title: '手机号码', dataIndex: 'mobile', key: 'mobile' },
    { title: '身份证', dataIndex: 'idCardNo', key: 'idCardNo' },
    { title: '意向楼盘', dataIndex: 'intentionProductName', key: 'intentionProductName' },
    { title: '参加人数', dataIndex: 'applyCnt', key: 'applyCnt' },
    { title: '报名时间', dataIndex: 'createTime', key: 'createTime' },
    { title: '签到时间', dataIndex: 'signTime', key: 'signTime' },
  ];
  const templateColumns = [
    { title: '表单名称', dataIndex: 'formTitle', key: 'formTitle' },
    { title: '类型', dataIndex: 'businessType', key: 'businessType' },
    { title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
  ]
  const sellerTableColumn = [
    {
      title: '项目名称', width: 100, dataIndex: 'productName', key: 'productId', render: (e, item) => {
        return item.name
      }
    },
    {
      title: '所属城市', width: 200, dataIndex: 'city', key: 'city', render: (a, item, index, d, e, f) => {
        //console.log(item)
        let arr = ['北京市', '重庆', '上海', '天津']
        if (arr.indexOf(item.provinceName) > -1) {
          return `${item.cityName}`
        } else {
          return `${item.provinceName || ''}${item.provinceName && item.cityName && ' - ' || ''}${item.cityName || ''}`
        }
      }
    },

  ];

  let sellerQueryList = [
    // {name: '区域公司', type: 'select', key: 'regionId',list:addressList,notNeedAll:true},
    { name: '省市', type: 'cascader', list: cloneDeep(areaList), key: ['province', 'city', 'county'], value: '' },
    { name: '项目名称', type: 'text', key: 'name', value: '' },
    { name: '', type: 'hidden', key: 'shelfStatus', value: '1' },
  ];

  const sellerSelectedColumn = [
    {
      title: '项目名称', width: 110, dataIndex: 'productName', key: 'productId', render: (e, item) => {
        return item.productName || item.name
      }
    },
    {
      title: '所属城市', dataIndex: 'cityName', key: 'cityName', render: (a, item, index, d, e, f) => {
        //console.log(item)
        // console.log(item)
        let arr = ['北京', '重庆', '上海', '天津']
        let provinceName = ''
        let cityName = ''
        // console.log(areaList.length)
        for (let i = 1; i < areaList.length; i++) {
          if (item.province == areaList[i].value) {
            provinceName = areaList[i].label
            if (arr.indexOf(provinceName) > -1) {
              provinceName = ''
            }
            for (let j = 0; j < areaList[i].children.length; j++) {
              if (item.city == areaList[i].children[j].value) {
                cityName = areaList[i].children[j].label
                // console.log(provinceName,cityName)
                return <span>{`${provinceName}${provinceName && '-'}${cityName}`}</span>
              }
            }
          }
        }

      }
    },


  ];

  const pagination = {
    current: Number(Enroll.pageNo || 1),
    pageNo: Number(Enroll.pageNo || 1),
    pageSize: Number(Enroll.pageSize || 10),
    total: Number(Enroll.total),
    showTotal: e => '共 ' + Enroll.total + ' 条',
    showSizeChanger: true,
    showQuickJumper: true,
    onChange: changePage, //分页事件
    onShowSizeChange: changePage, //每页条数
  }
  const status = [
    { name: '未上架', value: '0' },
    { name: '进行中', value: '1' },
    { name: '已结束', value: '2' }
  ]

  const mapQueryList = [
    { name: '省市', type: 'cascader', list: areaList, key: 'code', value: '' },
    { name: '分销商名称', type: 'text', key: 'sellerName', value: '' }
  ];
  //翻页函数
  function changePage(page, pageSize) {
    dispatch({
      type: `${namespace}/getEnroll`,
      payload: { pageNo: page, pageSize: pageSize, activityId: contentId }
    });
  }

  if (!!modelObj.biz) {
    pageProps.biz = modelObj.biz
    pageProps.biz.syncBackCbf = (biz) => {
      dispatch({
        type: `${namespace}/updateStore`,
        payload: { biz }
      })
    }
  }
  // 处理确定事件
  function handleOk(imgUrl) {
    console.log('裁剪后上传的图片地址为：', imgUrl);
    toggleDialog(false);
  }

  // 处理关闭事件
  function handleClose(e) {
    toggleDialog(false);
  }
  function showTypeModal() {
    dispatch({
      type: `${namespace}/updateStore`,
      payload: { TypeModalFlag: true }
    });
  }
  // 打开/关闭裁剪对话框
  function toggleDialog(visible) {
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { visible }
    });
  }
  function changeCity(value) {
    detail.province = value[0]
    detail.city = value[1]
    dispatch({
      type: `${namespace}/updateStore`,
      payload: { detail }
    });
    dispatch({
      type: `${namespace}/getBusinessList`,
      payload: { province: value[0], city: value[1] }
    })
  }

  //所有类型改变时（除date image）
  function inputChange(val, type, index) {
    console.log(val)
    if (type == 'isSelfTemplate') {
      detail[type] = val

      if (detail[type] === true) {
        detail.selfTemplateImg ? detail.bottomImg = detail.selfTemplateImg : detail.bottomImg = ""
      } else {
        detail.selfTemplateImg = detail.bottomImg
        detail.bottomImg = detail.bottomImg2
        detail.bottomImgId = detail.bottomImgId2
      }
    } else if (type == 'bottomImg') {
      detail[type] = val
      detail.bottomImg2 = val
      detail.bottomImgId = `active-${index}`
      detail.bottomImgId2 = `active-${index}`
    } else if (type == 'spreadName') {
      detail[type] = val
      detail.title = val
    } else {
      detail[type] = val
    }
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { detail }
    });
    if (detail.channel && detail.channel == 2 || detail.channel == 3) {
      dispatch({
        type: `${namespace}/updateModel`,
        payload: { showTime: false }
      });
    } else {
      dispatch({
        type: `${namespace}/updateModel`,
        payload: { showTime: true }
      });
    }
  }
  //图片删除时
  function removeImgUrl(type) {
    detail[type] = ''
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { detail }
    });
  }
  //图片增加时
  function updateImageModel(value, type) {
    detail[type] = value
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { detail }
    });
  };
  //date改变时
  function dateChange(date, dateString) {
    detail['startDate'] = dateString[0]
    detail['endDate'] = dateString[1]
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { detail }
    });
  }

  // 获取项目选项
  function getPorjectOption() {
    if (estateList) {
      return estateList.map((item, idx) =>
        <Select.Option key={idx} value={item.productId}>{item.name}</Select.Option>
      )
    } else {
      return null
    }
  }


  //编辑
  function edit() {
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { actionType: 'edit' }
    });
  }
  function hideTypeModal() {
    dispatch({
      type: `${namespace}/updateStore`,
      payload: { TypeModalFlag: false }
    });
  }
  //删除
  function deleteContent() {
    confirm({
      title: '删除确认',
      content: '您真的要删除此条资讯吗?',
      okText: '确认',
      okType: 'primary',
      cancelText: '取消',
      onOk() {
        dispatch({
          type: `${namespace}/deleteContent`
        })
      },
      onCancel() {
        console.log('Cancel');
      },
    });
  }
  function toDetail() {
    hashHistory.push({
      pathname: MODULE_TO_ROUTES[namespace].urlArray[0],
      query: { type: 'edit', }
    });
  }
  //提交
  function submit(type) {
    // console.log(detail)
    form.validateFields((err, values) => {
      console.log(err)
      if (!err) {
        dispatch({
          type: `${namespace}/submit`,
          payload:{type}
        })
      }
    });
  }
  const changeState = (payload) => {
    dispatch({
      type: `${namespace}/updateStore`,
      payload: { ...payload }
    })
  }
  function changeImgModal(visible = false, srcs = []) {
    console.log(imgModal)
    imgModal.visible = visible
    imgModal.srcs = srcs || modelObj.srcs
    changeState({ imgModal })
  }
  function capture(value, num) {
    // console.log(value,num)
    if (value) {
      value = value.substr(0, num)
    }
    return value
  }
  function handleEdit(value) {
    let param = { actionType, contentId }
    hashHistory.push({
      pathname: '/home/infoAdmin/templatesDetail',
      query: { actionType: "edit", id: value, hashUrl, param: JSON.stringify(param) }
    });

  }
  function handleDelete(value) {
    dispatch({
      type: `${namespace}/updateStore`, payload: {
        choiceType: '', choiceTypeTitle: ''
      }
    })
  }
  /*
    活动报名设置
  */
  function activityInputChange(value, type) {
    activityApply[type] = value;
    console.log(activityApply.isConfSign)
    if (type == 'relatProductType') {
      switch (value) {
        case '0':
          activityApply.relatCouponId = ""
          activityApply.relatGiftId = ""
          break;
        case '1':
          activityApply.relatGiftId = ""
          break;
        case '2':
          activityApply.relatCouponId = ""
          break;
        default:
          break;
      }
    } else if (type == "receiptFlag") {
      if (value == "0") {
        activityApply.enrollFee = "";
        activityApply.merchantCode = "";
      }
    }
    form.resetFields();
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { activityApply }
    });
  }



  /**
   * 活动项目配置
   */
  function checkAllChange(e) {
    resetFields();
    let resData = cloneDeep(projectData);
    if (e.target.checked) {
      let all = []
      estateList && estateList.forEach((e, i) => {
        all.push(e.productId + '')
      })
      resData.productIds = all
    } else {
      resData.productIds = []
    }
    dispatch({
      type: `${namespace}/updateStore`, payload: {
        indeterminate: false,
        checkAll: e.target.checked,
        projectData: resData
      }
    })
  }

  function checkAllChangeBack(value) {
    let all = []
    estateList && estateList.forEach((e, i) => {
      all.push(e.productId + '')
    })
    dispatch({
      type: `${namespace}/updateStore`, payload: {
        indeterminate: !!value.length && (value.length < all.length),
        checkAll: value.length === all.length
      }
    })
  }
  let choiceFormType = ""
  const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
      let choiceType = selectedRows[0].questionFormId
      choiceFormType = selectedRows[0].questionFormId
      let choiceTypeTitle = selectedRows[0].formTitle
      dispatch({
        type: `${namespace}/updateStore`, payload: {
          choiceType, choiceTypeTitle
        }
      })
    }
  };
  function updateMapmodel(status) {
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { Mapmodel: status }
    });
  }
  //弹出框回调
  function cbk( latAndLon,address) {
    activityApply.address = address
    activityApply.latAndLon = latAndLon
    dispatch({
      type: `${namespace}/updateModel`,
      payload: { activityApply }
    });
    form.resetFields(['address'])
  }

  // 活动日期  首页活动报名按钮​
  return (
    <div className={cx('pageLayout')}>
      <div className='public_listMain'>
        <div className={"functionButton"}>
          {actionType == "add" || actionType == "edit" ?
            <Button type='primary' onClick={e => submit('save')} loading={modelObj.btnLoading} disabled={!isSubmit}>保存</Button> : null}
          {actionType == "add"&&<Button type='primary' onClick={e => submit('saveAndPublish')}>发布</Button>}
          {/* {actionType == 'detail' ?
            <Button type='primary' onClick={e => deleteContent()} loading={modelObj.btnLoading}>删除</Button> : null}
          {actionType == 'detail' ?
            <Button type='primary' onClick={e => edit(contentId)}>编辑</Button> : null} */}
          {detail.published==0&&actionType != 'detail'&&<Button type='primary' onClick={e => submit('publish')}>发布</Button>}
          {detail.published==1&&actionType != 'detail'&&<Button type='primary' onClick={e => submit('unpublish')}>取消发布</Button>}
          {/* {actionType == 'detail' ?
            <Button type='primary' onClick={e => toDetail()}>查看报名明细</Button> : null} */}
        </div>
        {actionType!='detail'&&
          <Form>
          <div className="boxShadow">
            <div className={styles.box}>
              <CollapsiblePanels title='楼盘主页活动入口配置' hideUpDownBtn={true}>
                <Row>
                  {/* <Col span={6}>
                    <FormItem
                      {...formItemLayout}
                      extra={actionType=='detail'?'':'图片分辨率需为512px*336px，且文件大小在200kb以下，支持jpg，png格式。'}
                      disabled={actionType=='detail'}
                      required={true}
                      label="封面图">
                      <Uploader uploadedUrls={detail.titleImgUrl}
                                 removeFileCbf={() => { removeImgUrl('titleImgUrl') }}
                                 uploadSuccessCbf={(imgUrl) => { updateImageModel(imgUrl, 'titleImgUrl') }}
                                showType={'6'}
                                minCropBoxWidth={512}
                                minCropBoxHeight={336}
                                fileType='image'
                                fileMaxSize='0.2'
                                maxFiles='1' />
                      </FormItem>
                  </Col> */}
                  <Col span={12}>
                    <FormItem label='活动推广名称'  {...formItemLayout03}>
                      {getFieldDecorator('spreadName', {
                        rules: [{
                          required: true, message: '方案最多14个字', max: 14
                        }],
                        initialValue: detail.spreadName,
                      })(
                        <Input placeholder="方案最多14个字" onChange={(e) => { inputChange(e.target.value, 'spreadName') }} />
                      )}
                    </FormItem>
                  </Col>
                  {/* <Col span={4}>
									<Tooltip title="注：当超出该楼盘所有礼品领取时间则该礼品入口关闭"><Icon type="question-circle" style={{ fontSize: '16px', color: '#08c', marginLeft: '8px', marginTop: '8px' }} /></Tooltip>
								</Col> */}
                </Row>
                <Row>
                  {/* <Col span={}></Col> */}
                  <Col style={{ paddingLeft: '10' }}>楼盘主页入口样式选择：</Col>
                </Row>
                <Row>
                  <div style={{ "width": "100%" }}>
                    <div className={cx('box')}>
                      <FormItem >
                        {getFieldDecorator('bottomImg', {
                          initialValue: detail.bottomImg,
                          rules: [
                            { required: false, whitespace: true, message: '请选择活动图' },
                          ],
                        })(
                          <Radio.Group disabled={detail.isSelfTemplate === true}>
                            {gif.map((item, index) => {
                              return (
                                <div className={cx('preview')} key={index}>
                                  <img className={cx('imgBg')} src={item} alt="活动背景图" />
                                  <div className={cx('title')}>{capture(detail.spreadName, 14)}</div>
                                  <div className={cx('center')}><Radio value={detail.isSelfTemplate === true ? '' : item} onChange={(e) => { inputChange(e.target.value, 'bottomImg', index) }}>选择</Radio></div>
                                </div>
                              )
                            })}
                            <div className={cx('preview')}>
                              <Col span={8}>
                                <FormItem {...formItemLayout} >
                                  <Uploader
                                    uploadedUrls={detail.bottomImg}
                                    removeFileCbf={() => { removeImgUrl('bottomImg') }}
                                    uploadSuccessCbf={(imgUrl) => {
                                      updateImageModel(imgUrl, 'bottomImg')
                                    }}
                                    showType={detail.isSelfTemplate === false ? '' : "6"}
                                    // showType='3'
                                    minCropBoxWidth={343}
                                    minCropBoxHeight={90}
                                    unsetWidth={true}
                                    fileType='image'
                                    fileMaxSize='0.2'
                                    maxFiles='1'
                                  />
                                </FormItem>
                              </Col>
                              <Col style={{}} span={16}><span>{detail.isSelfTemplate === false ? '' : '图片分辨率需为343px*90px，且文件大小在200kb以下，支持jpg，png格式。'}</span></Col>
                              <Checkbox checked={detail.isSelfTemplate} onChange={e => { inputChange(e.target.checked, 'isSelfTemplate') }}>选择自定义配置图</Checkbox>
                            </div>
                          </Radio.Group>
                        )}
                      </FormItem>

                    </div>
                  </div>
                </Row>

              </CollapsiblePanels>
            </div>
            {/* <CollapsiblePanels title={'封面图'} hideUpDownBtn={true} >
                
              </CollapsiblePanels> */}

            <CollapsiblePanels title={actionType == 'add' ? '活动基本信息配置' : <div>活动内容
            {actionType && actionType == 'detail' ?
                <div className={cx('updateInfo')}><span>活动状态：{['未开始', '进行中', '已结束'][detail.status]}</span>  <span>创建人：{detail.creator}</span> <span>创建时间：{detail.createTime}</span> <span className={cx(detail.updatePerson ? '' : 'hidden')}>更新人：{detail.updatePerson}</span> <span className={cx(detail.updateTime ? '' : 'hidden')}>更新时间： {detail.updateTime}</span></div>
                : null}
            </div>} hideUpDownBtn={false} >
              <Row>
                <Col className="col" span={12}>
                  <FormItem
                    {...formItemLayout05}
                    extra={'图片分辨率需为1372px*672px，且文件大小在500kb以下，支持jpg，png格式。'}
                    disabled={actionType == 'detail'}
                    required={true}
                    label="封面图">
                    <div className={cx('uploaderBox')}>
                      <div className={cx('uploaderDiv')}>
                        <Uploader
                          uploadedUrls={detail.titleImgUrl}
                          removeFileCbf={() => { removeImgUrl('titleImgUrl') }}
                          uploadSuccessCbf={(imgUrl) => { updateImageModel(imgUrl, 'titleImgUrl') }}
                          showType={'6'}
                          minCropBoxWidth={1372}
                          minCropBoxHeight={672}
                          fileType='image'
                          fileMaxSize='0.5'
                          maxFiles='1' />
                      </div>
                      <div className={cx('tipBox')}>
                        <Icon type="question-circle" className={'mgr1'} style={{ color: '#08c' }} />
                        <a href="javascript:void(0)" onClick={() => { changeImgModal(true, [activity_cover_01]) }}>封面图显示在哪里?</a>
                      </div>
                    </div>

                  </FormItem>

                </Col>
              </Row>
              <Row>
                <Col className="col" span={12}>
                  <FormItem
                    {...formItemLayout05}
                    extra={'图片分辨率需为1500px*2668px，且文件大小在500kb以下，支持jpg，png格式。'}
                    disabled={actionType == 'detail'}
                    required={true}
                    label="分享海报">
                    <div className={cx('uploaderBox')}>
                      <div className={cx('uploaderDiv')}>
                        <Uploader
                          uploadedUrls={detail.sharingPosters}
                          removeFileCbf={() => { removeImgUrl('sharingPosters') }}
                          uploadSuccessCbf={(imgUrl) => { updateImageModel(imgUrl, 'sharingPosters') }}
                          showType={'6'}
                          minCropBoxWidth={1500}
                          minCropBoxHeight={2668}
                          fileType='image'
                          fileMaxSize='0.5'
                          maxFiles='1' />
                      </div>
                    </div>

                  </FormItem>

                </Col>
              </Row>
             
              <Row>
                <Col span={2}></Col>
                <Col span={7}>
                  <Checkbox checked={detail.isPublishHouse} onChange={e => { inputChange(e.target.checked, 'isPublishHouse') }} >是否同步发布到首页美房活动</Checkbox>
                  <Tooltip title="注：勾选后将会同步显示到美的置业云首页美房活动栏目中。"><Icon type="question-circle" className={cx('iconTip')} /></Tooltip>
                </Col>
                {/* <Col span={6}>
									<FormItem {...formItemLayout04} label="同步发布到首页美房活动">
										{getFieldDecorator('isPublishHouse', {
											rules: [{
												required: false
											}],
											initialValue: detail.isPublishHouse,
										})(
											<Row>
												<Checkbox checked={detail.isPublishHouse} onChange={e => { inputChange(e.target.checked, 'isPublishHouse') }} ></Checkbox>
												<Tooltip title="注：勾选后将会同步显示到美的置业云首页美房活动栏目中。"><Icon type="question-circle" className={cx('iconTip')} /></Tooltip>
											</Row>
										)}

									</FormItem>
								</Col> */}
                {detail.isPublishHouse &&

                  <Col className="col" span={14}>
                    <FormItem
                      {...formItemLayout02}
                      label='首页活动报名按钮'>
                      {getFieldDecorator('btnName', {
                        initialValue: detail.btnName,
                        rules: [
                          { required: true, whitespace: true, max: 5, message: '最多只能输入5个字符' },
                        ],
                      })(<Input style={{ width: '90%' }}
                        placeholder={'如：报名领大奖'}
                        disabled={actionType == 'detail'}
                        onChange={(e) => { inputChange(e.target.value, 'btnName') }}
                      />)}
                      {/* {detail.isPublishHouse &&
                        <Col span={4}> */}
                      <Icon type="question-circle" className={'mgr1'} style={{ fontSize: '16px', color: '#08c', marginLeft: '8px', marginTop: 12 }} onClick={() => { changeImgModal(true, [activity_apply_btn]) }} />
                      {/* </Col>
                      } */}
                    </FormItem>
                  </Col>
                }
              </Row>
              <Row>
                {/* <Col className="col" span={6}>
                  <FormItem
                    {...formItemLayout}
                    label='省市'>
                    {getFieldDecorator('city', {
                      initialValue: (detail.province ? [detail.province, detail.city] : '')
                    })(
                      <Cascader
                        options={areaList}
                        disabled={actionType == 'detail'}
                        onChange={changeCity}
                        placeholder={'请选择所属城市'}
                      // changeOnSelect
                      />
                    )}
                  </FormItem>
                </Col>
                <Col className="col" span={6}>
                  <FormItem
                    {...formItemLayout}
                    label='项目'>
                    {getFieldDecorator('businessId', {
                      initialValue: detail.projectName,
                      rules: [
                        { required: true, whitespace: true, message: '请先选择省市再选择项目' },
                      ],
                    })(
                      <Select
                        placeholder={"请选择项目"}
                        disabled={actionType == 'detail'}
                        onChange={(e) => inputChange(e, 'businessId')}>
                        {getPorjectOption()}
                      </Select>
                    )}
                  </FormItem>
                </Col> */}
                <Col className="col" span={12} >
                  <FormItem
                    {...formItemLayout05}
                    label='活动日期'>
                    {getFieldDecorator('date', {
                      initialValue: detail.startDate ? [moment(detail.startDate), moment(detail.endDate)] : null,
                      rules: [
                        { required: false, type: 'array', whitespace: true, message: '请选择活动日期' },
                      ],
                    })(<RangePicker
                      style={{ minWidth: 185, width: "100%" }}
                      format="YYYY-MM-DD HH:mm:ss"
                      locale={locale}
                      showTime
                      disabled={actionType == 'detail'}
                      onChange={(date, dateString) => dateChange(date, dateString)} />)}
                  </FormItem>
                </Col>
                <Col span={2}>
                  <Tooltip title="注：当超出该楼盘所有礼品领取时间则该礼品入口关闭"><Icon type="question-circle" className={cx('iconTip')} /></Tooltip>
                </Col>
                {/*
              <Col className="col" span={6}>
                <FormItem
                  {...formItemLayout}
                  label='资讯类型'>
                  {getFieldDecorator('channel', {
                    initialValue: detail.channel?detail.channel+'':'',
                    rules: [
                      { required: true, whitespace: true, message: '请选择类型' },
                    ],
                  })(<Select placeholder={"请选择类型"} onChange={(val) => inputChange(val, 'channel')} disabled={actionType == 'detail' ||actionType =="edit"}>
                    <Option value="1">动态资讯</Option>
                    <Option value="3">活动报名</Option>
                  </Select>)}
                </FormItem>
              </Col>
*/}
                {/* <Col className="col" span={8}>
                  <FormItem
                    {...formItemLayout}
                    label='标题'>
                    {getFieldDecorator('title', {
                      initialValue: detail.title,
                      rules: [
                        { required: true, whitespace: true, max: 30, message: '最多只能输入30个字' },
                      ],
                    })(<Input
                      placeholder={'请输入标题'}
                      disabled={actionType == 'detail'}
                      onChange={(e) => { inputChange(e.target.value, 'title') }}
                    />)}
                  </FormItem>
                </Col> */}
                {/* <Col className="col" span={6}>
                  <FormItem
                    {...formItemLayout}
                    label='活动状态'>
                    {getFieldDecorator('status', {
                      initialValue: detail.status,
                      rules: [
                        { required: true, whitespace: true,max:30, message: '最多只能输入30个字' },
                      ],
                    })(<Select
                      placeholder={"请选择活动状态"}
                      disabled={actionType == 'detail'}
                      onChange={(e) => inputChange(e, 'businessId')}>
                      {status.map((item,idx)=>{
                        return(
                          <option value={item.value}>{item.name}</option>
                        )
                      })}
                    </Select>)}
                  </FormItem>
                </Col> */}
              </Row>
              <Row>
                <Col span={6}>
                    <FormItem {...formItemLayout08} label="现场签到">
                      {getFieldDecorator('isConfSign', {
                        initialValue: activityApply.isConfSign,
                        rules: [
                          { required: true, whitespace: true, message: '请选择签到类型',type:'number'},
                        ],
                      })(
                        <Radio.Group onChange={(e) => activityInputChange(e.target.value, 'isConfSign')}>
                          <Radio value={1}>是</Radio>
                          <Radio value={0}>否</Radio>
                        </Radio.Group>
                      )}
                    </FormItem>
                  </Col>
                  <Col span={2} className={cx('tipBox2')}>
                      <Tooltip title="现场签到需要报名成功的用户现场扫签到码进行签到，可在活动列表-太阳码中下载签到码"><Icon type="question-circle" className={cx('iconTip')} /></Tooltip>
                    </Col>
              </Row>
              <Row>
                <Col className="col" span={24}>
                  <FormItem {...imageLayout}
                    label="活动地址">
                    {getFieldDecorator('address', {
                      rules: [
                        {
                          required: false,
                        },
                      ],
                    })(<Row style={{ border: 0 }}>
                    {actionType !== 'check'&& <Col span={2}><a onClick={(e) => { updateMapmodel(true) }}>选择地址</a></Col>}
                      <Col span={12}><span>{activityApply.address}</span></Col>
                      {activityApply.latAndLon && activityApply.latAndLon.length > 0 ? <Col>
                        <Col span={4}><span>经度:{activityApply.latAndLon[0]}</span>
                        </Col><Col span={4}>纬度:{activityApply.latAndLon[1]}</Col>
                      </Col> : null}
                    </Row>)}

                  </FormItem>
                </Col>
              </Row>
              {/* <Row >
              <Col className="col" span={6} hidden={actionType == 'detail'}>
                <FormItem
                  {...formItemLayout}
                  label='编辑方式'>
                  <RadioGroup onChange={(e) => { handleEditType(e) }} value={editValue}>
                    <Radio value={1}>编辑</Radio>
                    <Radio value={2}>外部链接</Radio>
                  </RadioGroup>
                </FormItem>
              </Col>
            </Row> */}
              {/* <Row>
              <Col className="col" span={6} >
                <FormItem
                  {...formItemLayout}
                  label='外部链接'>
                  {getFieldDecorator('link', {
                    initialValue: detail.link || null,
                    rules: [
                      { required: false, whitespace: true, message: '请输入外部链接' },
                    ],
                  })(<Input
                    disabled={disabledLink || actionType == 'detail'}
                    placeholder="请输入外部链接"
                    onChange={(e) => { !disabledLink ? inputChange(e.target.value, 'link') : null }}
                  />)}
                </FormItem>
              </Col>
            </Row> */}
            </CollapsiblePanels>
            <CollapsiblePanels title="活动报名配置" hideUpDownBtn={true}>
              <Row>
                <Col span={8}>
                  <FormItem {...formItemLayout} label="报名是否收费">
                    {getFieldDecorator('receiptFlag', {
                      initialValue: activityApply.receiptFlag,
                      rules: [
                        { required: true, whitespace: true, message: '请选择报名是否收费',type:'number' },
                      ],
                    })(
                      <Radio.Group onChange={(e) => activityInputChange(e.target.value, 'receiptFlag')}>
                        <Radio value={1}>是</Radio>
                        <Radio value={0}>否</Radio>
                      </Radio.Group>
                    )}
                  </FormItem>
                </Col>
                {activityApply.receiptFlag == '1' &&
                  <div>
                    <Col span={8}>
                      <FormItem label='报名费'  {...formItemLayout}>
                        {getFieldDecorator('enrollFee', {
                          rules: [
                            { required: activityApply.receiptFlag == '1', whitespace: true, message: '请输入报名费(支持2位小数)' },
                            { pattern: /(^[1-9](\d+)?(\.\d{1,2})?$)|(^0$)|(^\d\.\d{1,2}$)/, message: '请输入报名费(支持2位小数)' },
                          ],
                          initialValue: activityApply.enrollFee ? activityApply.enrollFee + "" : ""
                        })(
                          <Input disabled={activityApply.receiptFlag == '0'} placeholder='请输入报名费(支持2位小数)' onChange={(e) => { activityInputChange(e.target.value, 'enrollFee') }} />
                        )}
                      </FormItem>
                    </Col>
                    <Col span={8}>
                      <FormItem label='支付商户号'  {...formItemLayout}>

                        {getFieldDecorator('merchantCode', {
                          initialValue: activityApply.merchantCode,
                          rules: [
                            {
                              required: activityApply.receiptFlag == '1',
                              whitespace: true, message: '请选择支付商户号'
                            },
                          ],
                        })(
                          <Select
                            disabled={activityApply.receiptFlag == '0'}
                            onChange={(value) => activityInputChange(value, 'merchantCode')} placeholder="请选择支付商户号">

                            {payCodeList && payCodeList.map((item, i) => {
                              return (
                                <Select.Option value={item.merchantCode}>{item.merchantName}</Select.Option>
                              )
                            })}
                          </Select>
                        )}
                      </FormItem>
                    </Col>
                  </div>
                }
              </Row>
              <Row>
                <Col span={8}>
                  <FormItem {...formItemLayout} label="报名填写信息">
                   
                    {
                      getFieldDecorator('enrollFormKeys', {
                      initialValue: activityApply.enrollFormKeys,
                      rules: [
                        {
                          required: true, whitespace: true, message: '请选择报名填写信息',
                          validator: (rule, value, callback) => {
                            if (eval(value).length == 0&&!choiceTypeTitle) {
                              callback(rule.message);
                            } else {
                              callback();
                            }

                          }
                        },
                      ],
                    })(
                      <Checkbox.Group onChange={(e) => activityInputChange(e, 'enrollFormKeys')}>
                        <Checkbox value='NAME'>姓名</Checkbox>
                        <Checkbox value='IDCARDNO'>身份证</Checkbox>
                        <Checkbox value='PRODUCT'>意向楼盘</Checkbox>
                        <Checkbox value='MOBILE'>手机号码</Checkbox>
                        <Checkbox value='ACOUNT'>报名人数</Checkbox>
                      </Checkbox.Group>
                    )
                  
                  }
                    <span>选择表单模板：</span>
                    <span className={cx('selectForm')} onClick={() => showTypeModal()} >选择表单</span>
                    {choiceTypeTitle ? <p className={cx('FormTitle')}><span>{choiceTypeTitle}</span><em onClick={() => handleEdit(detail.questionFormId)}>编辑</em><em onClick={() => handleDelete(detail.questionFormId)}>删除</em></p> : ''}
                  </FormItem>
                  
                </Col>
                <Col span={8}>
                  <FormItem label='总报名人数限制'  {...formItemLayout}>
                    {getFieldDecorator('enrollLimit', {
                      rules: [
                        { required: false, whitespace: true, message: '请输入总报名人数限制' },
                        { pattern: /^[1-9]\d*$/, message: '请输入整数' },
                      ],
                      initialValue: activityApply.enrollLimit ? activityApply.enrollLimit + "" : ""
                    })(
                      <Input placeholder='请输入报名人数限制' onChange={(e) => { activityInputChange(e.target.value, 'enrollLimit') }} />
                    )}
                  </FormItem>
                </Col>
                <Col span={8}>
                  <FormItem {...formItemLayout} label="已报名人数">
                    {getFieldDecorator('showEnrolled', {
                      initialValue: activityApply.showEnrolled,
                      rules: [
                        { required: true, whitespace: true, message: '请选择已报名人数',type:'number' },
                      ],
                    })(
                      <Radio.Group onChange={(e) => activityInputChange(e.target.value, 'showEnrolled')}>
                        <Radio value={1}>显示</Radio>
                        <Radio value={0}>隐藏</Radio>
                      </Radio.Group>
                    )}
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={8}>
                  <FormItem {...formItemLayout} label="报名成功后获得">
                    {getFieldDecorator('relatProductType', {
                      initialValue: activityApply.relatProductType,
                      rules: [
                        {
                          required: true,
                          whitespace: true, message: '请选择关联商品分类',type:'number'
                        },
                      ],
                    })(
                      // notFoundContent={'该省市中无楼盘'}
                      <Select
                        // value={activityApply.relatProductType}
                        onChange={(value) => activityInputChange(value, 'relatProductType')} placeholder="请选择关联商品分类">
                        <Select.Option value={0}>无</Select.Option>
                        <Select.Option value={1}>优惠券</Select.Option>
                        <Select.Option value={2}>礼品</Select.Option>
                      </Select>
                    )}
                  </FormItem>
                </Col>
                <Col span={8}>
                  <FormItem {...formItemLayout} label="选择优惠券">
                    {getFieldDecorator('relatCouponId', {
                      initialValue: activityApply.relatCouponId,
                      rules: [
                        {
                          required: activityApply.relatProductType == '1',
                          whitespace: true, message: '请选择优惠券'
                        },
                      ],
                    })(
                      <Select
                        disabled={activityApply.relatProductType != '1'}
                        // value={activityApply.relatCouponId}
                        onChange={(value) => activityInputChange(value, 'relatCouponId')} placeholder="请选择优惠券">
                        {
                          discountCouponList && discountCouponList.map((item, index) => (
                            <Select.Option key={`discount_${index}`} value={item.couponsConfigId}>{item.name}</Select.Option>
                          ))
                        }
                      </Select>
                    )}
                  </FormItem>
                </Col>

                <Col span={8}>
                  <FormItem {...formItemLayout} label="选择礼品">
                    {getFieldDecorator('relatGiftId', {
                      initialValue: activityApply.relatGiftId,
                      rules: [
                        {
                          required: activityApply.relatProductType == '2',
                          whitespace: true, message: '请选择礼品'
                        },
                      ],
                    })(
                      <Select
                        disabled={activityApply.relatProductType != '2'}
                        // value={activityApply.relatGiftId}
                        onChange={(value) => activityInputChange(value, 'relatGiftId')} placeholder="请选择礼品">
                        {
                          giftList && giftList.map((item, index) => (
                            <Select.Option key={`gift_${index}`} value={item.giftId}>{item.title}</Select.Option>
                          ))
                        }
                      </Select>
                    )}
                  </FormItem>
                </Col>
              </Row>
            </CollapsiblePanels>
            <CollapsiblePanels title="活动项目配置" hideUpDownBtn={true} >
              <PopUpSelect
                tableColumn={sellerTableColumn}
                selectedColumn={sellerSelectedColumn}
                selectedTableScroll={{ x: 420 }}
                queryList={cloneDeep(sellerQueryList)}
                isSave={true}
                refreshByEnter={true}
                requestUrl='admin/estate/adminList'
                title='选择工程名称'
                respListKey='rows'
                idKey='productId'
                onItem={selectItem}
                onChange={(e) => {
                  let productIds = []
                  e.map((item) => {
                    productIds.push(item.productId)
                  })
                  projectData.productIds = Array.from(new Set(productIds))
                  dispatch({
                    type: `${namespace}/updateStore`,
                    payload: { projectData, selectItem: e }
                  })
                }}
              ></PopUpSelect>
            </CollapsiblePanels>
            <CollapsiblePanels title="活动介绍" hideUpDownBtn={true}>
              <Row style={{ display: showEditor }}>
                <Col className="col" span={24} >
                  <FormItem
                    // {...formItemLayout}
                    {...{ labelCol: { span: 2 }, wrapperCol: { span: 22 } }}
                    label='活动介绍'>
                    {(
                      <div>
                        {/* {actionType !== 'detail'&&<span style={{fontSize:12,fontWeight: "normal"}}>注：图文编辑的图片上传尺寸建议：1372px*736px</span>} */}
                        <Col span={15}><span style={{ fontSize: 12, fontWeight: "normal" }}>注：图文编辑的图片上传尺寸建议：1372px*736px</span></Col>

                        <span >
                          <Icon type="question-circle" className={'mgr1'} style={{ color: '#08c' }} />
                          <a href="javascript:void(0)" onClick={() => { changeImgModal(true, [activityDetail_demo]) }}>查看示例</a>
                        </span>

                        <Ueditor id="activityDetail"
                          style={{ width: '100%', height: 900 }}
                          editable={actionType === 'detail' ? false : true}
                          html={detail.detail || ''}
                          title={detail.title || ''}
                          startDate={detail.startDate || ''}
                          endDate={detail.endDate || ''}
                          height={500}
                          isSubmit={isSubmit}
                          inputChange={e => {
                            dispatch({ type: `${namespace}/dealEditor`, payload: { detail: e } })
                          }}
                          isSubmit={
                            e => { dispatch({ type: `${namespace}/updateStore`, payload: { isSubmit: e.isSubmit } }) }
                          }
                        />

                        {/* <KingEditor
                          id={'infoDetail'}
                          style={{ width: '100%', height: 400 }}
                          editable={actionType === 'detail'?false:true}
                          html={detail.detail||''}
                          inputChange={e => {
                            dispatch({ type: `${namespace}/dealEditor`, payload: { detail: e } })
                          }} 
                        />*/}
                      </div>
                    )}
                  </FormItem>
                </Col>
              </Row>
            </CollapsiblePanels>
          </div>
        </Form>
        }
        
      </div>

      {actionType && actionType == 'detail' ?
        <CollapsiblePanels title="活动报名信息" hideUpDownBtn={true} >
          <Row className={'mgb1'}>
            <Col span={12}>
              <span className={'mgr2'}>报名人数：{Enroll ? Enroll.total : '0'}人</span>
              <span className={'mgr2'}> 参加人数：{Enroll.applyCnt ? Enroll.applyCnt : '0'}人</span>
              <span className={'mgr2'}> 签到人数：{activityApply.isConfSign===1 ? Enroll.signCount : '0'}人</span>

            </Col>
            <Col span={12} >
              <Button type="primary" style={{ float: 'right' }} loading={modelObj.exportLoading} onClick={() => {
                dispatch({
                  type: `${namespace}/downLoad`,
                  payload: { activityId }
                })
              }}>导出</Button>
            </Col>
          </Row>
          <div style={{ position: 'relative' }}>

            {/* <ListPage pageProps={pageProps}/> */}
            <Table
              columns={activityApply.isConfSign===1?columns1:columns}
              dataSource={listData}
              pagination={pagination}
            />
          </div>

        </CollapsiblePanels>
        : null
      }
      <Modal title={'示例图'}
        onCancel={() => { changeImgModal(false) }}
        onOk={() => { changeImgModal(false) }}
        footer={null}
        width={'80%'}
        visible={imgModal.visible}>
        <Row justify={'space-between'} align={'middle'} type={'flex'}>
          {imgModal.srcs.length == 1 &&
            <Col span={24} style={{ display: 'flex', justifyContent: 'center' }}>
              <img style={{ height: '600px' }} className={cx('demoImg')} src={imgModal.srcs[0]} alt="" />
            </Col>
          }
          {imgModal.srcs.length == 2 &&
            <Col span={24}>
              <img width={'49%'} src={imgModal.srcs[0]} alt="" />
              <img width={'49%'} className={'fr'} src={imgModal.srcs[1]} alt="" />
            </Col>
          }
        </Row>
      </Modal>
      <Modal
        title="表单列表"
        maskClosable={true}
        onCancel={() => { hideTypeModal() }}
        onOk={() => {
          /* if(!choiceFormType){
             message.warning('请选表单')
             return
           }*/

          hideTypeModal()
        }}
        visible={TypeModalFlag}
      >
        <Table
          pagination={false}
          rowSelection={{ type: 'radio', ...rowSelection }}
          columns={templateColumns}
          dataSource={templatesList}
        />
      </Modal>
      <Track
        visible={Mapmodel}
        queryList={mapQueryList}
        btnDiv={true}
        latAndLon={activityApply.latAndLon||[]}
        cancal={e => updateMapmodel(false)}
        cbk={(v, b) => cbk(v, b)}
        options={areaList}
      />
    </div>



  )
}

// 连接视图(view)和模型(model)
export default connect(mapStateToProps)(Form.create()(routeView))
